package com.zy.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.zy.common.pojo.TreeNode;
import com.zy.common.util.TaotaoResult;
import com.zy.service.ContentCategoryService;

@Controller
@ResponseBody
@RequestMapping("/content/category")
public class ContentCategoryController {

	@Autowired
	private ContentCategoryService contentCategoryService;
	
	/**
	 * 内容分类管理列表
	 * @param parentId
	 * @return
	 */
	@RequestMapping("/list")
	public List<TreeNode> getContentList(@RequestParam(value="id",defaultValue="0") long parentId){
		List<TreeNode> categoryList = contentCategoryService.getContentCategoryList(parentId);
		return categoryList;
	}
	
	/**
	 * 新增内容管理节点
	 */
	@RequestMapping("/create")
	public TaotaoResult createContentCategory(long parentId, String name) {
		TaotaoResult result = contentCategoryService.insertContentCategory(parentId, name);
		return result;
	}
}
